package com.hntky.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 周宇轩
 * @date 2023/5/1 16:44
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private String code;
    private String msg;
    private Object data;

    /**
     * 不携带数据返回给前台的信息
     * @return
     */
    public static Result success() {
        return new Result("200", "请求成功", null);
    }

    /**
     * 携带数据返回给前台的信息
     * @param data
     * @return
     */
    public static Result success(Object data) {
        return new Result("200", "请求成功", data);
    }

    /**
     * 请求失败
     * @return
     */
    public static Result error(String code, String msg) {
        return new Result(code, msg, null);
    }
}
